home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / gdb-4.5 / dist / libiberty / getpagesize.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-01  |  2.0 KB  |  80 lines

  1. /* Emulation of getpagesize() for systems that need it.
  2.    Copyright (C) 1991 Free Software Foundation, Inc.
  3.  
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8.  
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. GNU General Public License for more details.
  13.  
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  17.  
  18. /*
  19.  
  20. NAME
  21.  
  22.     getpagesize -- return the number of bytes in page of memory
  23.  
  24. SYNOPSIS
  25.  
  26.     int getpagesize (void)
  27.  
  28. DESCRIPTION
  29.  
  30.     Returns the number of bytes in a page of memory.  This is the
  31.     granularity of many of the system memory management routines.
  32.     No guarantee is made as to whether or not it is the same as the
  33.     basic memory management hardware page size.
  34.  
  35. BUGS
  36.  
  37.     Is intended as a reasonable replacement for systems where this
  38.     is not provided as a system call.  The value of 4096 may or may
  39.     not be correct for the systems where it is returned as the default
  40.     value.
  41.  
  42. */
  43.  
  44.  
  45. #include <sys/types.h>
  46. #include <sys/param.h>
  47.  
  48. #ifdef USGr4
  49. #include <unistd.h>
  50. #define GNU_OUR_PAGESIZE sysconf(_SC_PAGESIZE)
  51. #else
  52. #ifdef    PAGESIZE
  53. #define    GNU_OUR_PAGESIZE PAGESIZE
  54. #else    /* no PAGESIZE */
  55. #ifdef    EXEC_PAGESIZE
  56. #define    GNU_OUR_PAGESIZE EXEC_PAGESIZE
  57. #else    /* no EXEC_PAGESIZE */
  58. #ifdef    NBPG
  59. #define    GNU_OUR_PAGESIZE (NBPG * CLSIZE)
  60. #ifndef    CLSIZE
  61. #define    CLSIZE 1
  62. #endif    /* CLSIZE */
  63. #else    /* no NBPG */
  64. #ifdef    NBPC
  65. #define    GNU_OUR_PAGESIZE NBPC
  66. #else    /* no NBPC */
  67. #define    GNU_OUR_PAGESIZE 4096    /* Just punt and use reasonable value */
  68. #endif /* NBPC */
  69. #endif /* NBPG */
  70. #endif /* EXEC_PAGESIZE */
  71. #endif /* PAGESIZE */
  72. #endif /* USGr4 */
  73.  
  74. int
  75. getpagesize ()
  76. {
  77.   return (GNU_OUR_PAGESIZE);
  78. }
  79.  
  80.